﻿@{
    ViewBag.Title = "ViewPage1";
    Layout = "~/Views/Shared/BaseView.cshtml";
}
@{
    Common.Web.Cookie cookie = new Common.Web.Cookie();
    int visiterId = Convert.ToInt32(cookie.GetCookie("LoginUserId"));
    BenefitHelper.DB.DBManager db = new BenefitHelper.DB.DBManager();
    if (BenefitHelper.Sys.VisitPrower.HasAdminPrower(visiterId, db))
    { 
    <div id="buttons">
        <span>
            <p>
                <a href="/Init" target="_blank" title="后台管理">后台管理</a>
            </p>
        </span>
    </div>
    }
    db.Dispose();
}
<dl id="xiangmu">
    <dt><span id="title2">@ViewBag.op.UName</span></dt>
    <dd>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" id="panzhongfenxi">
            <tr>
                <td id="curr_p">
                    <b class="panzhong"><a>盘中分析</a></b><b><a href="/AfterAnalysis/Index/@ViewBag.uid/@ViewBag.pdate">盘后分析</a></b>
                </td>
                <td>
                    <a href="/OperatorRealtimeTransaction/Index/@ViewBag.uid/@ViewBag.pdate">
                        <img src="/Content/images/icon_01.gif" />汇总信息</a>
                </td>
                <td>
                    <a href="/TimeSharing/Index/@ViewBag.uid/@ViewBag.pdate">
                        <img src="/Content/images/icon_09.gif" />持仓分析</a>
                </td>
                <td>
                    <a href="/ProfitAndLossDistribution/Index/@ViewBag.uid/@ViewBag.pdate">
                        <img src="/Content/images/icon_10.gif" />盈亏分布</a>
                </td>
                <td class="selected">
                    <img src="/Content/images/icon_05.gif" />交易明细
                </td>
            </tr>
        </table>
    </dd>
</dl>
<div id="bigDataBox">
    <span style="width: 50%;">数据统计时间：
        <input type="text" id="key" class="Wdate" onclick="WdatePicker()" name="key" value="@ViewBag.Hpdate"  /><span
            style="padding-left: 24px;"><span style="cursor: pointer;"><input type="button" value="查看"
                style="font-size: 9pt; width: 60px; height: 22px;" id="changedate" /></span></span></span>
    <div>
        <div style="height: 5px; line-height: 5px;">
        </div>
        <div style="width: 60%; background-repeat: no-repeat; float: left; text-align: left;">
            <img src="/content/images/zijingzhuangkuang.png" />
        </div>
        <table cellspacing="0" cellpadding="0" class="list" style="width: 100%;">
            <tr>
                <td style="text-align: center;" class="title">
                </td>
                <td style="text-align: center;" class="title">
                    期初结存
                </td>
                <td style="text-align: center;" class="title">
                    期末结存
                </td>
                <td style="text-align: center;" class="title">
                    期末净持仓
                </td>
                <td style="text-align: center;" class="title">
                    当日入金
                </td>
                <td style="text-align: center;" class="title">
                    当日出金
                </td>
                @*            <td style="text-align: center;" class="title">
                    手续费返还
                </td>*@
                <td style="text-align: center;" class="title">
                    风险度
                </td>
            </tr>
            @foreach (BenefitHelper.Data.Day.AccountDayMoney money in ViewBag.accountMoneys)
            {
                <tr class="detailslist acc">
                    <td>
                        @money.Account.AccountName
                    </td>
                    <td style="text-align: right;">
                        @string.Format("{0:N2}", money.PresetTlePosit)
                    </td>
                    <td style="text-align: right;">
                        @string.Format("{0:N2}", money.SettlePosit)
                    </td>
                    <td style="text-align: right;">
                        @Convert.ToInt32(money.LongPosition + money.ShortPosition)
                    </td>
                    <td style="text-align: right;">
                        @string.Format("{0:N2}", money.Deposit)
                    </td>
                    <td style="text-align: right;">
                        @string.Format("{0:N2}", money.WithDraw)
                    </td>
                    @*               <td>
                        0
                    </td>*@
                    <td class="leftyes" style="text-align: right;">
                        @Convert.ToInt32(money.RiskRate * 100) %
                    </td>
                </tr>
            }
            <tr id="ad" onclick="showDetail('acc')" class="detailsold" title="点击查看更多">
                <td class="bottomyes">
                    合计
                </td>
                <td class="bottomyes" style="text-align: right;">
                    @string.Format("{0:N2}", ViewBag.operatorMoney.PresetTlePosit)
                </td>
                <td class="bottomyes" style="text-align: right;">
                    @string.Format("{0:N2}", ViewBag.operatorMoney.SettlePosit)
                </td>
                <td class="bottomyes" style="text-align: right;">
                    @Convert.ToInt32(ViewBag.operatorMoney.ShortPosition + ViewBag.operatorMoney.LongPosition)
                </td>
                <td class="bottomyes" style="text-align: right;">
                    @string.Format("{0:N2}", ViewBag.operatorMoney.Deposit)
                </td>
                <td class="bottomyes" style="text-align: right;">
                    @string.Format("{0:N2}", ViewBag.operatorMoney.WithDraw)
                </td>
                @*                <td class="bottomyes">
                    0
                </td>*@
                <td class="bottomyes leftyes" style="text-align: right;">
                    @Convert.ToInt32(ViewBag.operatorMoney.RiskRate * 100) %
                </td>
            </tr>
        </table>
    </div>
    <div style="height: 5px; line-height: 5px;">
    </div>
    <table style="width: 100%; height: 160px;">
        <tr>
            <td style="width: 50%; vertical-align: top;">
                <div style="width: 100%; height: 130px;" id="showflash4">
                </div>
            </td>
            <td style="width: 50%; vertical-align: top;">
                <div style="width: 100%; height: 130px;" id="showflash2">
                </div>
            </td>
        </tr>
    </table>
    <div style="height: 5px; line-height: 5px;">
    </div>
    <div style="height: 5px; line-height: 5px;">
    </div>
    <div style="width: 60%; background-repeat: no-repeat; float: left; text-align: left;">
        <img src="/content/images/jiaoyitongji.png" />
    </div>
    <table cellspacing="0" cellpadding="0" class="list" style="width: 100%;" id="producttable">
        <tr>
            <td style="text-align: center;" class="title">
                品种
            </td>
            <td style="text-align: center;" class="title">
                多空
            </td>
            <td style="text-align: center;" class="title">
                盈亏
            </td>
            @*   <td style="text-align: center;" class="title">
                交易次数
            </td>*@
            <td style="text-align: center;" class="title">
                手数
            </td>
            <td style="text-align: center;" class="title">
                净利润
            </td>
            <td style="text-align: center;" class="title">
                平均每手利润
            </td>
            @*  <td style="text-align: center;" class="title">
                平均每手利润
            </td>*@
        </tr>
        <!--表格正文-->
        @foreach (BenefitHelper.View.OperatorDayProductInfo info in ViewBag.infos)
        {
            if (info.ProductId.IndexOf("_#1") <= 0)
            {
            <tr class="detailsold" onclick="showDetail('@info.ProductId')" id="@info.ProductId">
                <td title="">
                    <b>@info.ProductId</b>
                </td>
                <td>
                    @info.Direction
                </td>
                <td>
                    @info.WinOrLost
                </td>
                @*    <td style="text-align: right;">
                    @info.BillCount
                </td>*@
                <td style="text-align: right;">
                    @info.BillCount
                </td>
                <td style="text-align: right;">
                    @string.Format("{0:N2}", info.DayCount)
                </td>
                <td style="text-align: right;" class="leftyes">
                    @string.Format("{0:N2}", info.AvgBillProfit)
                </td>
            </tr>
            }
            else
            {
            <tr class='detailslist @info.ProductId.ToString().Replace("_#1", "")'>
                <td title="">
                    <b>-</b>
                </td>
                <td>
                    @info.Direction
                </td>
                <td>
                    @info.WinOrLost
                </td>
                @*  <td style="text-align: right;">
                    @info.BillCount
                </td>*@
                <td style="text-align: right;">
                    @info.BillCount
                </td>
                <td style="text-align: right;">
                    @string.Format("{0:N2}", info.DayCount)
                </td>
                <td style="text-align: right;" class="leftyes">
                    @string.Format("{0:N2}", info.AvgBillProfit)
                </td>
            </tr>
            }

        }
    </table>
    <div style="height: 5px; line-height: 5px;">
    </div>
    <div style="height: 10px; line-height: 10px;">
    </div>
    <div style="width: 420px; background-repeat: no-repeat; float: left; text-align: left;">
        <img src="/content/images/chicangmingxi.png" />
    </div>
    <div class="date-select-bar" style="float: right; width: 320px;">
        <a class='cur abutton' onclick="changediv('all',this)">所有账号</a>
        @foreach (BenefitHelper.Data.Day.AccountDayMoney money in ViewBag.accountMoneys)
        {
            <a style="cursor:pointer;" class="abutton" onclick='changediv("@money.AccountId",this)'>
                账号 @money.Account.AccountName</a>
        }
    </div>
    <table cellspacing="0" cellpadding="0" class="list" style="width: 100%;">
        <tr>
            <td style="text-align: center;" class="title">
                时间
            </td>
            <td style="text-align: center;" class="title">
                价格
            </td>
            <td style="text-align: center;" class="title">
                合约
            </td>
            <td style="text-align: center;" class="title">
                买/卖
            </td>
            <td style="text-align: center;" class="title">
                手数
            </td>
            <td style="text-align: center;" class="title">
                浮动盈亏
            </td>
            <td style="text-align: center;" class="title">
                占用保证金
            </td>
        </tr>
        <!--表格正文-->
        @{
            int billcount = 0;
            double fudongyingki = 0f;
            double margin = 0f;
        }
        @foreach (BenefitHelper.View.OperatorDayPosition accountdayposition in ViewBag.allPosition)
        {
            <tr class="@accountdayposition.AccountId positiondiv">
                <td title="">
                    @{
                  if (accountdayposition.OpenTime.ToString().Length == 5)
                  {
                        @(accountdayposition.OpenTime.ToString().Substring(0, 1) + ":" + accountdayposition.OpenTime.ToString().Substring(1, 2) + ":" + accountdayposition.OpenTime.ToString().Substring(3))
                  }
                  else
                  {
                        @(accountdayposition.OpenTime.ToString().Substring(0, 2) + ":" + accountdayposition.OpenTime.ToString().Substring(2, 2) + ":" + accountdayposition.OpenTime.ToString().Substring(4))
                  }
                    }
                </td>
                <td style="text-align: right;">
                    @string.Format("{0:N2}", accountdayposition.OpenPrice)
                </td>
                <td>
                    @accountdayposition.InstrumentId
                </td>
                <td>
                    @if (accountdayposition.Direction.Equals("0"))
                    {
                        <span>买</span>
                    }
                    else
                    {
                        <span>卖</span>
                    }
                </td>
                <td style="text-align: right;">
                    @accountdayposition.Volume
                    @{billcount += accountdayposition.Volume;}
                </td>
                <td style="text-align: right;">
                    @string.Format("{0:N2}", accountdayposition.PositionProfit)
                    @{fudongyingki += accountdayposition.PositionProfit;
                    }
                </td>
                <td class="leftyes" style="text-align: right;">
                    @string.Format("{0:N2}", accountdayposition.Margin)
                    @{margin += accountdayposition.Margin;
                    }
                </td>
            </tr>
        }
        <tr>
            <td title="" class="bottomyes">
                合计
            </td>
            <td class="bottomyes">
            </td>
            <td class="bottomyes">
            </td>
            <td class="bottomyes">
            </td>
            <td class="bottomyes" style="text-align: right;">
                @billcount
            </td>
            <td class="bottomyes" style="text-align: right;">
                @string.Format("{0:N2}", fudongyingki)
            </td>
            <td class="leftyes bottomyes" style="text-align: right;">
                @string.Format("{0:N2}", margin)
            </td>
        </tr>
    </table>
    <div style="height: 5px; line-height: 5px;">
    </div>
    <div class="report-tip">
        <div class="report-tip-text">
            <div>
                <b>功能说明：</b></div>
            <div>
                亏损性成交：相对于当前（统计时间显示的时间）股票价格，在所有当日已经的成交中对于买入用户处于亏损的成交分布。<br />
                获利性成交：相对于当前（统计时间显示的时间）股票价格，在所有当日已经的成交中对于买入用户处于获利的成交分布。<br />
                成交均价：所有处于亏损或获利的不同成交单子中进行统计，平均成交价格。</div>
        </div>
        <div class="report-tip-close">
            &nbsp;</div>
        <div class="report-tip-text">
            <div>
                <b>使用帮助：</b></div>
            <div>
                本内容主要是将大小单成交与获利与亏损结合起来，以便于用户可以通过分析来获取有利于交易的市场交易习惯和潜在交易机会。</div>
        </div>
        <div class="report-tip-text">
            <div>
                <b>数据更新：</b></div>
            <div>
                盘中数据动态更新，更新间隔5分钟，由于运算因素，实时成交数据整体延时约5-10分钟。</div>
        </div>
    </div>
</div>
@MvcHtmlString.Create(ViewBag.js)
<script type="text/javascript">

    $(document).ready(function () {
        $(".detailsold:last td").each(function () {
            $(this).addClass("bottomyes");
        });
    });


    function showDetail(pid) {
        if ($('#ad').attr('class') == "detailsold") {
            $("#ad").removeClass("detailsold").addClass("detailsoldclick");
        } else {
            $("#ad").removeClass("detailsoldclick").addClass("detailsold");
        }
        $("." + pid).toggle();
        $("#producttable tr:last td").each(function () {
            $(this).addClass("bottomyes");
        });

        if ($(".detailsold:last").attr("id") == pid) {
            $(".detailsold:last td").each(function () {

                if ($("." + pid).css("display") == "none") {
                    $(this).addClass("bottomyes");
                } else {
                    $(this).removeClass("bottomyes");
                }
            });
        }

    }
    TickPie();
    TickPie2();


    function changediv(id, obj) {
        $(".abutton").removeClass("cur");
        $(obj).addClass("cur");
        if (id != "all") {
            $(".positiondiv").each(function () {
                $(this).css("display", "none");
            });
            $("." + id).css("display", "");
        } else {
            $(".positiondiv").each(function () {
                $(this).css("display", "");
            });
        }
    }

    function fr() {
        window.open("/tradedetail/showdetails", "成交明细");
    }
</script>
